FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
# COPY ./sources.list /etc/apt/sources.list
RUN apt update -y && apt install wget git -y
RUN wget https://golang.google.cn/dl/go1.18.5.linux-amd64.tar.gz -O /opt/go1.18.5.linux-amd64.tar.gz && tar -C /usr/local -xzvf /opt/go1.18.5.linux-amd64.tar.gz && rm -rf /opt/go*
RUN ln -s /usr/local/go/bin/go /usr/local/bin/go && go version
# COPY ./ /opt/openstack_api/
WORKDIR /opt
RUN git clone https://gitee.com/yachonglee/openstack_api.git

RUN export GOPROXY=https://proxy.golang.com.cn,direct &&  cd /opt/openstack_api/ && ls -alh && go mod tidy && go build main.go
WORKDIR /opt/openstack_api/vnc/
RUN apt install python3-pip -y
RUN pip install --upgrade pip setuptools==45.2.0
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN apt install libsm-dev libxrender-dev ffmpeg vim  -y
WORKDIR /opt/openstack_api/
CMD ["bash","-c", "git pull; cd /opt/openstack_api; go build main.go;  /opt/openstack_api/main" ]
#docker run -d --name=openstack_api --hostname=openstack_api --env=DEBIAN_FRONTEND=noninteractive --volume=/var/www/vncscreencap:/var/www/vncscreencap --volume=/var/www/vncscreenshot:/var/www/vncscreenshot --volume=/var/log:/var/log --volume=/etc/config.yml:/etc/config.yml --network=host --workdir=/opt/openstack_api/vnc --restart=always   openstack_api

